
package pat;
import java.util.Scanner;

//import java.math.BigInteger;
//import java.util.Scanner;
//import java.util.Vector;
//
//public class CountingOnes {
//
//	public static void main(String[] args) {
//
//		int count = 0;
//		Scanner s = new Scanner(System.in);
//		BigInteger bt = new BigInteger(s.next());
//		Vector<Character> v = new Vector<Character>();
//		for (long i = 1; i <= bt.longValue(); i++) {
//			String str = String.valueOf(i);
//			for (int j = 0; j < str.length(); j++) {
//				if (str.charAt(j) == '1')
//				{
//					count++;
//				}
//			}
//			v.removeAllElements();
//		}
//		System.out.print(count);
//	}
//}

public class CountingOnes {
	public static int Count(int n) {
		int ans = 0;
		int base = 1;
		// count "1" in every digit, then sum
		while (n / base != 0) {
			int right = n % base;// low digit
			int left = n / (base * 10);// high digit
			int now = (n / base) % 10;// current digit
			if (now == 0)// current digit 0, then only determined by high digit
				ans += left * base;
			else if (now == 1)// current digit 1, then determined by both high
								// and low digit
				ans += left * base + right + 1;
			else
				// current digit > 1
				ans += (left + 1) * base;
			base *= 10;
		}
		return ans;
	}

	public static void main(String[] args) {
	
		Scanner s = new Scanner(System.in);
		int n=s.nextInt();
		int ans = Count(n);
		System.out.println(ans);

	}
}